#ifndef __AUTO_LINK_HPP__
#define __AUTO_LINK_HPP__

#	define STRINGIZE(X) DO_STRINGIZE(X)
#	define DO_STRINGIZE(X) #X

#	ifndef AUTO_LINK_LIB_NAME
#		error("please define AUTO_LINK_LIB_NAME by your lib name before include this file!")
#	else
#		pragma message("auto link : link lib name = " STRINGIZE(AUTO_LINK_LIB_NAME))
#	endif// AUTO_LINK_LIB_NAME

#	ifndef AUTO_LINK_LIB_VERSION
#		define AUTO_LINK_LIB_VERSION
#	else
#		pragma message("auto link : link lib version = " AUTO_LINK_LIB_VERSION)
#	endif// AUTO_LINK_LIB_VER
//
// msvc version
//
#	ifdef _MSC_VER
#		ifndef AUTO_LINK_LIB_TOOLSET
#			if	_MSC_VER < 1300
#				define AUTO_LINK_LIB_TOOLSET "vc6"
#			elif _MSC_VER == 1300
#				define AUTO_LINK_LIB_TOOLSET "vc7"
#			elif _MSC_VER == 1310
#				define AUTO_LINK_LIB_TOOLSET "vc71"
#			elif _MSC_VER == 1400
#				define AUTO_LINK_LIB_TOOLSET "vc80"
#			elif _MSC_VER == 1500
#				define AUTO_LINK_LIB_TOOLSET "vc90"
#			elif _MSC_VER == 1600
#				define AUTO_LINK_LIB_TOOLSET "vc100"
#			elif _MSC_VER == 1700
#				define AUTO_LINK_LIB_TOOLSET "vc110"
#			else
#				error "unknown msvc version!"
#			endif// _MSC_VER
#		endif// AUTO_LINK_LIB_TOOLSET
#		pragma message("auto link : msvc toolset = " AUTO_LINK_LIB_TOOLSET)
#	else
#		error "only applicable in msvc"
#	endif// _MSC_VER
//
// runtime library
//
#	ifdef _MT
#		define LIB_THREAD_OPT "-mt"
#	else
#		define LIB_THREAD_OPT
#	endif// _MT
//
// debug or release build
//
#	ifdef _DEBUG
#		define LIB_BUILD_OPT "-debug"
#	else
#		define LIB_BUILD_OPT "-release"
#	endif// _DEBUG
//
// link static lib or dynamic lib
//
#	ifdef _DLL
#		define LIB_LINK_OPT	"-dynamic"
#	else
#		define LIB_LINK_OPT "-static"
#	endif
#	pragma message("auto link : linking to lib file " STRINGIZE(AUTO_LINK_LIB_NAME) "-" AUTO_LINK_LIB_TOOLSET LIB_THREAD_OPT LIB_BUILD_OPT LIB_LINK_OPT "-" AUTO_LINK_LIB_VERSION ".lib")
#	pragma comment(lib, "auto link : linking to lib file " STRINGIZE(AUTO_LINK_LIB_NAME) "-" AUTO_LINK_LIB_TOOLSET LIB_THREAD_OPT LIB_BUILD_OPT LIB_LINK_OPT "-" AUTO_LINK_LIB_VERSION ".lib")
#endif// __AUTO_LINK_HPP__
#undef DO_STRINGIZE
#undef STRINGIZE